package com.rzcf.blink.pay;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import top.tangyh.basic.validator.annotation.EnableFormValidator;

import java.net.InetAddress;
import java.net.UnknownHostException;

import static top.tangyh.lamp.common.constant.BizConstant.BUSINESS_PACKAGE;
import static top.tangyh.lamp.common.constant.BizConstant.UTIL_PACKAGE;

@SpringBootApplication
@Configurable
@EnableDiscoveryClient
@Slf4j
@EnableFormValidator
@ComponentScan({UTIL_PACKAGE, BUSINESS_PACKAGE, "com.rzcf.blink.zh"})
@EnableFeignClients(value = {UTIL_PACKAGE, BUSINESS_PACKAGE, "com.rzcf.blink.zh"})
@MapperScan("com.rzcf.blink.pay.infrastructure.persistent.mapper")
public class Application {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
        Environment env = application.getEnvironment();
        log.info("(♥◠‿◠)ﾉﾞ  pay服务模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "#  ,---.  ,---.  ____     __  .-'''-.    ____     \n" +
                "#  |   /  |   |  \\   \\   /  // _     \\ .'  __ `.  \n" +
                "#  |  |   |  .'   \\  _. /  '(`' )/`--'/   '  \\  \\ \n" +
                "#  |  | _ |  |     _( )_ .'(_ o _).   |___|  /  | \n" +
                "#  |  _( )_  | ___(_ o _)'  (_,_). '.    _.-`   | \n" +
                "#  \\ (_ o._) /|   |(_,_)'  .---.  \\  :.'   _    | \n" +
                "#   \\ (_,_) / |   `-'  /   \\    `-'  ||  _( )_  | \n" +
                "#    \\     /   \\      /     \\       / \\ (_ o _) / \n" +
                "#     `---`     `-..-'       `-...-'   '.(_,_).'  \n" +
                "#                                                 ");
        log.info("\n----------------------------------------------------------\n\t" +
                        "应用 '{}' 启动成功! 访问连接:\n\t" +
                        "Swagger文档: \t\thttp://{}:{}/doc.html\n\t" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port", "8080"));
    }

}
